home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ARK.ARJ / SND.PAS < prev    next >
Pascal/Delphi Source File  |  1994-02-20  |  3KB  |  125 lines

  1. {$F+}
  2.  
  3. unit snd;
  4.  
  5. interface
  6.  
  7. var
  8.    sound_on  : boolean;
  9.    snd_delay : longint;
  10.    use_sb    : boolean;
  11.  
  12. procedure DetectFM;
  13. procedure MakeNote(nota,attack,del : integer);
  14. procedure Start_level;
  15. procedure ball_block_sound(freq,duration : integer);
  16. procedure Death_sound(w : integer);
  17.  
  18. implementation
  19. uses crt,mouse,FM;
  20.  
  21. type
  22.   InsArray = array[0..29] of byte;
  23.  
  24. const
  25.   Piano1 : InsArray = ( 0,00,  1, 1, 3,15, 5, 0, 1, 3,15, 0, 0, 0, 0,  0, 1, 0,13, 7, 0, 2, 4,16, 0, 0, 1, 0,  0,0);
  26.   BDrum1 : InsArray = ( 1,06,  0, 0, 0,10, 4, 0, 8,12,11, 0, 0, 0, 0,  0, 0,47,13, 4, 0, 6,15,16, 0, 0, 0, 1,  0,0);
  27.   Snare1 : InsArray = ( 1,07,  0,12, 0,15,11, 0, 8, 5,16, 0, 0, 0, 1,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  0,0);
  28.   Tom1   : InsArray = ( 1,08,  0, 4, 0,15,11, 0, 7, 5,16, 0, 0, 0, 1,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  0,0);
  29.   Cymbal1: InsArray = ( 1,09,  0, 1, 0,15,11, 0, 5, 5,16, 0, 0, 0, 1,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  0,0);
  30.   HiHat1 : InsArray = ( 1,10,  0, 1, 0,15,11, 0, 7, 5,16, 0, 0, 0, 1,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  0,0);
  31.  
  32.  
  33. procedure MakeNote(nota,attack,del : integer);
  34.    begin
  35.    if sound_on then sound(nota);
  36.    mydelay(attack);
  37.    nosound;
  38.    mydelay(del);
  39.    end;
  40.  
  41. procedure ball_block_sound(freq,duration : integer);
  42.    begin
  43.    if not use_sb then
  44.       begin
  45.       nosound;
  46.       if sound_on then sound(freq);
  47.       end
  48.    else
  49.       if sound_on then
  50.          begin
  51.          KeyOff(1);
  52.          if(freq<700) then KeyOn(1,freq shr 3)
  53.          else if freq=700 then KeyOn(1,70)
  54.          else if freq=2000 then KeyOn(1,80);
  55.          end;
  56.  
  57.    snd_delay:=duration;
  58.    end;
  59.  
  60. procedure SB_note(voice,note,del : integer);
  61.    begin
  62.    KeyOn(voice,note);
  63.    KeyOn(voice+1,note+4);
  64.    KeyOn(voice+2,note+7);
  65.  
  66.    mydelay(del);
  67.  
  68.    KeyOff(voice);
  69.    KeyOff(voice+1);
  70.    KeyOff(voice+2);
  71.    end;
  72.  
  73. procedure start_level;
  74. const ottava = 3;
  75.  
  76.    begin
  77.    if not use_sb then
  78.       begin
  79.       MakeNote(396,40,2);  { Sol }
  80.       MakeNote(468,56,2);  { La# }
  81.       MakeNote(440, 8,2);  { La  }
  82.       MakeNote(396, 8,2);  { Sol }
  83.       MakeNote(352, 8,2);  { Fa  }
  84.       MakeNote(440, 8,2);  { La  }
  85.       MakeNote(396,40,2);  { Sol }
  86.       end
  87.    else if sound_on then
  88.       begin
  89.       AllKeyOff;
  90.  
  91.       AssignVoice(1,InsData(Cymbal1));
  92.       AssignVoice(2,InsData(Piano1));
  93.       AssignVoice(3,InsData(Snare1));
  94.  
  95.       SB_note(1,6+ottava*12,40);
  96.       SB_note(1,9+ottava*12,56);
  97.       SB_note(1,8+ottava*12,12);
  98.       SB_note(1,6+ottava*12,12);
  99.       SB_note(1,4+ottava*12,12);
  100.       SB_note(1,8+ottava*12,12);
  101.       SB_note(1,6+ottava*12,40);
  102.  
  103.       AssignVoice(1,InsData(Tom1));
  104.       end;
  105.    end;
  106.  
  107. procedure DetectFM;
  108.  
  109. var
  110.   SBP : word;
  111.  
  112. begin {DetectFm}
  113.   use_sb:=TRUE;
  114.   SBP := FindSBPBasePort;
  115.   if not FindBasePort then use_sb:=FALSE;
  116. end; {DetectFM}
  117.  
  118.  
  119. procedure Death_sound(w : integer);
  120.    begin
  121.    if not use_sb then MakeNote(400-w*50,8,2)
  122.    else if sound_on then SB_note(1,13-w,8);
  123.    end;
  124.  
  125. end.